﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="true"
    CodeFile="BangDonViTinh.aspx.cs" Inherits="WebTeamplate.Admin_BangDonViTinh" %>

<%@ Register Assembly="Control" Namespace="Kng.Controls" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

    <script src="../Js/BasicFunction.js"></script>

    <script src="../Js/ListView.js"></script>

    <table class="lvtBg" border="0" cellpadding="0" cellspacing="1" width="100%">
        <tbody>
            <tr>
                <td align="center">
                    <table class="small" border="0" cellpadding="2" cellspacing="5" width="100%">
                        <tr>
                            <td align="right" style="width: 150px;">
                                <asp:Label ID="lblLoaiHangHoa" Text="Chọn loại hàng hóa:" runat="server">
                                </asp:Label>
                            </td>
                            <td align="left">
                                <asp:DropDownList ID="drlLoaiHangHoa" runat="server" AutoPostBack="True" OnSelectedIndexChanged="drlLoaiHangHoa_SelectedIndexChanged">
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="refvLoaiHangHoa" ControlToValidate="drlLoaiHangHoa" runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                            <asp:Label ID="lblDVT" Text="Đơn vị tính:" runat="server">
                                </asp:Label>
                            </td>
                            <td align="left">
                                <asp:CheckBoxList ID="cblDonViTinh" RepeatColumns="3" CellPadding="5"
                                    CellSpacing="10" runat="server"></asp:CheckBoxList>
                                <cc1:RequiredFieldValidatorForCheckBoxLists ID="refvDVT" ErrorMessage="Vui lòng chọn đơn vị tính" Display="Static" ControlToValidate="cblDonViTinh"  runat="server">*
                                </cc1:RequiredFieldValidatorForCheckBoxLists>
                              
                            </td>
                        </tr>
                        <tr>
                            <td>
                            </td>
                            <td align="left">
                                <asp:Button ID="btnSave" runat="server" Text="Lưu" meta:resourcekey="btnSearchResource1" CausesValidation="true"
                                    CssClass="crmbutton small edit" OnClick="btnSave_Click" />
                                <asp:Button ID="btnCancel" runat="server" Text="Lưu" meta:resourcekey="btnSearchResource1" CausesValidation="false"
                                    CssClass="crmbutton small edit" OnClick="btnCancel_Click" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                            </td>
                            <td>
                                <asp:ValidationSummary ID="vsumCategory" CssClass="validateSumary" DisplayMode="BulletList"
                                    runat="server" ShowMessageBox="true" ShowSummary="false" />
                                <asp:Label ID="lblErrorMessage" runat="server" CssClass="validateSumary"></asp:Label>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    <hr noshade="noshade" size="1">
                </td>
            </tr>
            <tr>
                <td>
                    <!-- List View's Buttons and Filters starts -->
                    <table class="small" border="0" cellpadding="2" cellspacing="0" width="100%">
                        <tbody>
                            <tr>
                                <!-- Buttons -->
                                <td style="padding-right: 20px;" nowrap="nowrap">
                                    <asp:Button ID="btnDelete" CssClass="crmbutton small edit" Text="Delete" runat="server"
                                        meta:resourcekey="btnDeleteResource1" OnClientClick="return CheckDelete();" OnClick="btnDelete_Click" />
                                </td>
                                <td class="small" nowrap="nowrap" align="right">
                                    &nbsp;
                                </td>
                                <td>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="4">
                                    &nbsp;
                                </td>
                            </tr>
                        </tbody>
                    </table>
                    <!-- List View's Buttons and Filters ends -->
                    <div>
                        <table class="lvt small" border="0" cellpadding="3" cellspacing="1" width="100%">
                            <!-- Table Headers -->
                            <tbody>
                                <tr>
                                    <td class="lvtCol" style="width: 40px;">
                                        <input id="chkCheckAll" name="chkCheckAll" onclick='ChekAll(this.checked)' type="checkbox">
                                    </td>
                                    <td class="lvtCol" style="width: 40px;">
                                        <%=Resources.Resource.LABEL_NO %>
                                    </td>
                                    <td class="lvtCol">
                                        Tên đơn vị tính
                                    </td>
                                    <td class="lvtCol" style="width: 80px;">
                                        <%=Resources.Resource.LABEL_ORDER %>
                                    </td>
                                    <td class="lvtCol" style="width: 80px;">
                                        <%=Resources.Resource.LABEL_PUBLISH %>
                                    </td>
                                    <td class="lvtCol" style="width: 80px;">
                                        <%=Resources.Resource.LABEL_ACTION %>
                                    </td>
                                </tr>
                                <!-- Table Contents -->
                                <asp:Repeater ID="rptData" runat="server" OnItemDataBound="rptData_ItemDataBound"
                                    OnItemCommand="rptData_ItemCommand">
                                    <ItemTemplate>
                                        <tr class="lvtColData" onmouseover="this.className='lvtColDataHover'" onmouseout="this.className='lvtColData'"
                                            id="row_89" bgcolor="white">
                                            <td class="repeaterCenterData">
                                                <input type="checkbox" name="chk_<%#Eval("SubCategoryId") %>" id="chk_<%#Eval("SubCategoryId") %>"
                                                    onclick="CheckItem('<%#Eval("SubCategoryId") %>',this.checked);" />
                                            </td>
                                            <td class="repeaterCenterData">
                                                <asp:Literal ID="ltrNo" runat="server"></asp:Literal>
                                            </td>
                                            <td class="repeaterLeftData">
                                                <asp:Literal ID="ltrSubName" runat="server"></asp:Literal>
                                            </td>
                                            <td class="repeaterCenterData">
                                                <asp:ImageButton ID="imgOrderDown" CausesValidation="false" runat="server" ImageUrl="~/App_Themes/Admin/images/tick.png"
                                                    CommandName="OrderDown" />
                                                <asp:ImageButton ID="imgOrderUp" CausesValidation="false" runat="server" ImageUrl="~/App_Themes/Admin/images/tick.png"
                                                    CommandName="OrderUp" />
                                            </td>
                                            <td class="repeaterCenterData">
                                                <asp:ImageButton ID="btnPublish" runat="server" ImageUrl="~/App_Themes/Admin/images/tick.png"
                                                    CommandName="publish" />
                                            </td>
                                            <td class="repeaterCenterData">
                                                <asp:LinkButton ID="lbtnDelete" CausesValidation="false" runat="server" Text="Delete" CommandName="delete"
                                                    OnClientClick="return ConfirmDelete();"></asp:LinkButton>
                                            </td>
                                        </tr>
                                    </ItemTemplate>
                                </asp:Repeater>
                            </tbody>
                        </table>
                    </div>
                </td>
            </tr>
        </tbody>
    </table>
    <input type="hidden" id="hidListId" runat="server" value="" />
    <input type="hidden" id="hidListIdSelect" runat="server" value="" />

    <script type="text/javascript">

        function ClearFrom() {


            return false;
        }
        // return the value of the radio button that is checked
        function ConfirmDelete() {
            var yes = confirm('<%=Resources.Resource.MESSAGE_CONFIRM_DELETE %>');
            return yes;
        }
        function CheckDelete() {

            var id = document.getElementById('<%=hidListIdSelect.ClientID %>').value;
            if (id == '') {
                alert('<%=Resources.Resource.MESSAGE_REQUIRE_SELECT_ITEM %>');
                return false;
            }
            else return ConfirmDelete();

        }
        function CheckItem(id, status) {

            var idSelect = document.getElementById('<%=hidListIdSelect.ClientID %>').value;
            if (status) {
                idSelect += id + ';';
            }
            else idSelect = idSelect.replace(id + ';', '');
            if (idSelect.length == document.getElementById('<%=hidListId.ClientID %>').value.length) {
                document.getElementById('chkCheckAll').checked = true;
            }
            else
                document.getElementById('chkCheckAll').checked = false;
            document.getElementById('<%=hidListIdSelect.ClientID %>').value = idSelect;
        }
        function ChekAll(status) {

            var id = document.getElementById('<%=hidListId.ClientID %>').value;
            var arr = new Array();
            arr = id.split(';');
            if (arr.length > 0) {
                for (var i = 0; i < arr.length; i++) {
                    if (document.getElementById('chk_' + arr[i].toString())) {
                        document.getElementById('chk_' + arr[i].toString()).checked = status;

                    }
                }

            }
            if (status) {
                document.getElementById('<%=hidListIdSelect.ClientID %>').value = id;
            }
            else document.getElementById('<%=hidListIdSelect.ClientID %>').value = '';
        }
       
    </script>

</asp:Content>
